var io = require('socket.io-client');

var socket = io.connect(getwebsocket());

function gethost(){
    //return 'localhost';
    return '192.168.39.94';
}

function getwebsocket(){
    return 'http://' + gethost() + ':3001';
}

function geturl(){
    return 'http://' + gethost() + ':3000/';
}

function onwebsocket(key,cb){
    socket.on(key,(data) =>{
        cb(data);
    });
}

function websocketemit(key,data){
    socket.emit(key,data);
}

module.exports = {
    onwebsocket,
    websocketemit,
    geturl,
}